package zzbds;

import java.util.Scanner;

public class zzbdsdem7 {
    public static void main(String[] args) {
        //要求 ：大小写字母，数字，下划线一共4-16位
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名");
        String username = sc.next();
        boolean flag1 = cheakusername(username);
        if (flag1) {
            System.out.println("满足");
        } else {
            System.out.println("不满足");
        }
        System.out.println("请输入身份证号码");
        String peronID = sc.next();
        boolean flag2 = cheakPersonID(peronID);
        if (flag2) {
            System.out.println("满足");
        } else {
            System.out.println("不满足");
        }
    }

    private static boolean cheakPersonID(String peronID) {
        String regex ="[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}(\\d|X|x)";

        return peronID.matches(regex);
    }

    /*private static boolean cheakPersonID(String peronID) {
        String regex = "[1-9]\\d{16}[xX\\d]";
        return peronID.matches(regex);
    }*/

    private static boolean cheakusername(String username) {

        String regex = "\\w{4,16}";
        return username.matches(regex);
    }
}
